/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.ekaaty.converter;

import br.com.ekaaty.bean.Evento;
import br.com.ekaaty.bean.Faculdade;
import br.com.ekaaty.dao.EventoDao;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

/**
 *
 * @author otavio
 */
@FacesConverter(value="evento", forClass=Evento.class)
public class EventoConverter implements Converter{

     @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {

       int valor=Integer.parseInt(value);
       EventoDao eventoDao= new EventoDao();
       Object evento=eventoDao.recuperar(valor);
       return evento;
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {

      Evento evento=(Evento)value;
       return String.valueOf(evento.getCodigo());
    }

}
